//
//  MCGetDayWageActiveUserConditionModel.m
//  XDYL
//
//  Created by MC on 2018/4/2.
//  Copyright © 2018年 TLYL01. All rights reserved.
//

#import "MCGetDayWageActiveUserConditionModel.h"
#import "NSDictionary+helper.h"
#import "NSString+Helper.h"

@interface MCGetDayWageActiveUserConditionModel ()<ApiManagerCallBackProtocol,ApiManagerProvider,ApiManagerProtocol>
{
    
    NSDictionary * _dic;
}
@end

@implementation MCGetDayWageActiveUserConditionModel

- (instancetype)initWithDic:(NSDictionary *)dic{
    
    if (self = [super init]) {
        _dic = dic;
    }
    return self;
}



- (void)setValue:(id)value forUndefinedKey:(NSString *)key{
    
};
-(BOOL)isShowHud{
    return YES;
}
- (BOOL)isShowError{
    return NO;
}
- (BOOL)isShowNoNet{
    return NO;
}
- (BOOL)isShowNodata{
    return NO;
}
- (enum ManagerRequestMethod)requestMethod{
    
    return ManagerRequestMethodRequestMethodRestPOST;
}

- (enum APIResponseDataType)responseDataType{
    
    return APIResponseDataTypeJson;
}
- (void)refreashDataAndShow{
    
    ApiBaseManager *baseManager = [[ApiBaseManager alloc] initWithUrlProvider:self];
    baseManager.apiCallBackDelegate = self;
    baseManager.requestCustomizeDelegate = self;
    [baseManager loadData];
    
}

- (NSDictionary<NSString *,NSString *> *)headerForManagerWithManager:(ApiBaseManager *)manager{
    
    NSString *Token=@"";
    if ([[NSUserDefaults standardUserDefaults] objectForKey:@"token"]) {
        Token=[[NSUserDefaults standardUserDefaults] objectForKey:@"token"];
    }
    
    return @{@"token":Token,@"platformCode":@"5"};
}

- (NSString *)urlPathComponentForManagerWithManager:(ApiBaseManager *)manager{
    
    return @"web-api/api/v4/get_daywages_active_user";
    
}

- (NSDictionary<NSString *,id> *)parametersForManagerWithManager:(ApiBaseManager *)manager{
    
    NSString *timeString = [NSString getCurrentTimestamp];
    
    NSDictionary *dic =_dic;
    
    NSString *jsonStr = [dic convertToJsonData];
    NSString *sign = [NSString stringWithFormat:@"%@%@%@",jsonStr,[[NSUserDefaults standardUserDefaults] objectForKey:@"token"],timeString];
    return @{@"params":jsonStr,
             @"sign":[sign MD5],
             @"timestamp":timeString
             };
}

- (void)managerCallAPIDidSuccessWithManager:(ApiBaseManager *)manager{
    
    [BKIndicationView dismiss];
    if (self.callBackSuccessBlock) {
        self.callBackSuccessBlock(manager.ResponseRawData);
    }
    
}

- (void)managerCallAPIDidFailedWithManager:(ApiBaseManager *)manager errorCode:(NSString *)errorCode{
    [BKIndicationView dismiss];
    if (self.callBackFailedBlock) {
        self.callBackFailedBlock(manager,errorCode);
    }
    NSLog(@"er=----%@",errorCode);
}



@end

@implementation MCGetDaywagesActiveUserModel

singleton_m(MCGetDaywagesActiveUserModel)
//@property (nonatomic,strong) NSString * Recharge;
//@property (nonatomic,strong) NSString * Consumption;
//@property (nonatomic,strong) NSString * Tip;
//        {
//            "code": 200,
//            "message": "成功",
//            "data": {
//                "Consumption": 100,
//                "Recharge": 0
//            }
//        }

//当 Recharge 有大于 0 的值时，显示：当日充值量大于 Recharge 元为活跃用户。
//当 Consumption 有大于 0 的值时，显示：当日投注量大于 Consumption 元为活跃用户。

-(void)setTipWithData:(NSDictionary *)dic{
    self.Consumption=[NSString stringWithFormat:@"%@",dic[@"Consumption"]];
    self.Recharge=[NSString stringWithFormat:@"%@",dic[@"Recharge"]];
    if (self.Consumption.length>0) {
        self.Consumption=GetRealSNum(self.Consumption);
    }
    if (self.Recharge.length>0) {
        self.Recharge=GetRealSNum(self.Recharge);
    }
    
    if (([self.Consumption integerValue]>0)&&([self.Recharge integerValue]>0)) {
        self.Tip=[NSString stringWithFormat:@"当日充值量大于%@元并且当日投注量大于%@元为活跃用户",self.Consumption,self.Recharge];
    }else if ([self.Recharge integerValue]>0){
        self.Tip=[NSString stringWithFormat:@"当日充值量大于%@元为活跃用户",self.Recharge];
    }else if ([self.Consumption integerValue]>0){
        self.Tip=[NSString stringWithFormat:@"当日投注量大于%@元为活跃用户",self.Consumption];
    }else{
        self.Tip=@"  ";
    }
}
@end




























